<template>
  <div class="tab-ul">
    <div class="tab-li"
         :class="{'active': props.modelValue === 0}"
         @click="onTab(0)"
    >职位</div>
    <div class="slide"></div>
    <div class="tab-li"
         :class="{'active': props.modelValue === 1}"
         @click="onTab(1)"
    >人才库</div>
    <div class="slide"></div>
    <div class="tab-li"
         :class="{'active': props.modelValue === 2}"
         @click="onTab(2)"
    >社区</div>
    <div class="active-li" :style="activeLiStyle"></div>
  </div>
</template>

<script lang="ts" setup>
import {computed, ref} from "vue";

const props = defineProps({
  modelValue: {
    type: Number,
    default: 0
  },
})
const emits = defineEmits(['update:modelValue'])
const onTab = (index:number) => {
  emits('update:modelValue', index)
}
const activeLiStyle = computed(() => {
  console.log(props.modelValue * 200)
  return {left: props.modelValue * 200 + 'rpx'}
})

</script>

<style lang="scss" scoped>
.tab-ul {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 80rpx;
  .tab-li {
    width: 200rpx;
    height: 44rpx;
    font-size: 32rpx;
    font-weight: 300;
    color: #0D3333;
    line-height: 44rpx;
    text-align: center;
    z-index: 9;
    //cursor: pointer;
    &.active {
      color: #000000;
    }
  }
  .slide {
    width: 2rpx;
    height: 24rpx;
    background: rgba(0, 0, 0, 0.25);
  }
  .active-li {
    width: 200rpx;
    height: 16rpx;
    position: absolute;
    bottom: -5rpx;
    transition:all 0.2s ease-in-out;
    &:after {
      position: absolute;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      content: '';
      width: 156rpx;
      height: 16rpx;
      background: #24FAF6;
      border-radius: 20rpx;
    }
  }
}
</style>
